package org.aceor.funny.common.http.retrofit.parser;


import org.aceor.funny.common.http.retrofit.serializer.Serializer;
import org.aceor.funny.common.http.executor.ResultCallback;
import org.aceor.funny.common.http.utils.HttpMethod;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.http.Header;

import java.lang.reflect.Type;
import java.util.Map;

/**
 * Created by lxue on 15/11/20.
 */
public class HttpRequest<T> {

    String url;
    HttpMethod method;
    boolean isMultipart;
    boolean hasBody;
    boolean isFormEncoded;
    Map<String,Object> data;
    ResultCallback<T> callback;
    Header[] headers;
    Type clazz;
    Type returnClazz;
    boolean async;
    Serializer obj;

    public HttpRequest(String url, HttpMethod method, boolean isMultipart, boolean hasBody, boolean isFormEncoded, Map<String, Object> data, Header[] headers, ResultCallback callback, Type clazz, Type returnClazz, boolean async) {
        this.url = url;
        this.method = method;
        this.isMultipart = isMultipart;
        this.hasBody = hasBody;
        this.isFormEncoded = isFormEncoded;
        this.data = data;
        this.callback = callback;
        this.headers = headers;
        this.clazz = clazz;
        this.async = async;
        this.returnClazz = returnClazz;
    }

    public String getUrl() {
        return url;
    }

    public HttpMethod getMethod() {
        return method;
    }

    public boolean isMultipart() {
        return isMultipart;
    }

    public boolean isHasBody() {
        return hasBody;
    }

    public boolean isFormEncoded() {
        return isFormEncoded;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public ResultCallback getCallback() {
        return callback;
    }

    public Header[] getHeaders() {
        return headers;
    }

    public Type getClazz() {
        return clazz;
    }

    public Serializer getObj() {
        return obj;
    }

    public void setObj(Serializer obj) {
        this.obj = obj;
    }

    public Type getReturnClazz() {
        return returnClazz;
    }

    public boolean isAsync() {
        return async;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
